<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>楼盘更多</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">标题</label>
			<label class="layui-input-inline">
				${item.name}
			</label>
			</div>
		<!--<div class="layui-inline">
			<a class="layui-btn layui-btn-normal addBtn" data-title="添加" data-url="/hostItemMore/getEntity?itemId=${item.id}">添加</a>
		</div>-->
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit"> 编辑 </a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'form', 'pageUtil', 'table', 'dateUtil', 'fileUtil','baseUtil'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            form = layui.form,
            table = layui.table,
			baseUtil = layui.baseUtil,
            pageUtil = layui.pageUtil;
        var tableIns = null;
        var itemId = '${item.id}';
        var url = "/hostItemMore/page?itemId="+itemId;
        var cols = [{
            type: 'checkbox',
            fixed: 'left'
        },
            {
                type: 'numbers',
                title: '序号'
            },
            {
                field: 'name',
                title: '名称',
                align: 'center'
            },
            {
                field: 'value',
                title: '值(点击修改)',
                align: 'center',
				edit: 'text'
            },
			{
				field: 'unit',
				title: '单位',
				align: 'center'
			},
            {
                field: 'orderNum',
                title: '排序',
                align: 'center'
            },
            {
                field: 'createTime',
                title: '创建时间',
                width: 190,
                align: 'center',
                templet: function(d) {
                    return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd HH:mm:ss");
                }
            },
            {
                title: '操作',
                width: 150,
                align: "center",
                fixed: 'right',
                templet: function(d) {
                    return '<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit"> 编辑 </a><!--\
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >-->';
                }
            }];
        tableIns = pageUtil.initDate(cols, url, true);

		//监听单元格编辑
		table.on('edit(entityList)', function(obj){
			var value = obj.value //得到修改后的值
					,data = obj.data //得到所在行所有键值
					,field = obj.field; //得到字段
			// layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
			baseUtil.postMethodResult("/hostItemMore/updateValue", {id:data.id,value:value},
					function(result) {
						layer.msg('值修改成功');
					});
		});

        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/hostItemMore/getEntity?id=" + data.id);
                } else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/hostItemMore/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                }
            });
    })</script>
</body>

</html>